package magicArt;

import src.margicArt.R;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Gravity;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

/**
 * 简单的登录画面而已
 * 
 * @author 王宇云
 * 
 */
public class LoginActivity extends Activity {

	/** 用户名 */
	private EditText editText;

	/** 战斗按钮 */
	private Button toFight;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.login);
		// 用户名输入框
		editText = (EditText) findViewById(R.id.userName);
		// 按钮
		toFight = (Button) findViewById(R.id.play);
		toFight.setOnClickListener(new ToFightLintener());
	}

	/**
	 * 登录成功，切换至战斗画面
	 * 
	 */
	class ToFightLintener implements OnClickListener {

		public void onClick(View v) {
			// 用户输入了用户名
			String user = editText.getText().toString();
			if (!"".equals(user)) {
				Intent intent = new Intent();
				intent.setClass(LoginActivity.this, MargicArtActivity.class);
				LoginActivity.this.startActivity(intent);
			} else {
				Toast toast = Toast.makeText(LoginActivity.this, "少侠请留名", Toast.LENGTH_SHORT);
				toast.setGravity(Gravity.AXIS_CLIP, 0, 0);
				toast.show();
			}
		}
	}

}
